package com.tulele.vtool.task.async;

import com.tulele.vtool.service.IUserCommodityInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AddUserPlatformCommodityAsyncTask {

    @Autowired
    private IUserCommodityInfoService userCommodityInfoService;

    /**
     * 异步添加商品信息
     * @param userId
     * @param brandId
     */
    @Async
    public void addUserPlatformCommodityAsyncTask(Integer userId, Integer brandId) {

        //查询该用户的该品牌是否已经有文章，没有则直接添加
        int userBrandCommodityCount = userCommodityInfoService.getUserBrandCommodityCount(userId, brandId);

        if (userBrandCommodityCount == 0) {

            userCommodityInfoService.addUserPlatformCommodityInfo(userId, brandId);

        }

    }

}
